-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use warnings.warn instead of logger.warning #321
Conversation
smart_open/smart_open_lib.py
Outdated
@@ -382,7 +382,7 @@ def open( | |||
|
|||
def smart_open(uri, mode="rb", **kw): | |||
"""Deprecated, use smart_open.open instead.""" | |||
logger.warning('this function is deprecated, use smart_open.open instead') | |||
warnings.warn('this function is deprecated, use smart_open.open instead') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we link to the smart_open
=> open
migration instructions here? This "use smart_open.open instead" is a massive ask, unless it's a 1:1 transparent swap without any potential issues (which I don't think it is).
Let's inform the user more clearly what are the expected tradeoffs / benefits of such change, and what their migration and potential incompatibilities look like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
Submitting a few minor rewording suggestions.
README.rst
Outdated
Since 1.8.1, there is a `smart_open.open` function that replaces `smart_open.smart_open`. | ||
The new function offers several advantages over the old one: | ||
|
||
- 100% compatible with the built-in open function (aka io.open): it accepts all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 100% compatible with the built-in open function (aka io.open): it accepts all | |
- 100% compatible with the built-in `open` function (aka `io.open`): it accepts all |
README.rst
Outdated
|
||
- 100% compatible with the built-in open function (aka io.open): it accepts all | ||
the parameters that the built-in open accepts. | ||
- Default open mode is now "r", the same as for the built-in open |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Default open mode is now "r", the same as for the built-in open | |
- The default `smart_open.open` mode is now "r", the same as for the built-in `open` (`smart_open.smart_open` default used to be "rb"). |
README.rst
Outdated
- Default open mode is now "r", the same as for the built-in open | ||
- Fully documented keyword parameters (try `help("smart_open.open")`) | ||
|
||
These instructions will help you migrate to the new function painlessly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These instructions will help you migrate to the new function painlessly. | |
The instructions below will help you migrate to the new function painlessly. |
|
||
warnings.warn( | ||
'This function is deprecated, use smart_open.open instead. ' | ||
'See the migration notes for details: %s' % _MIGRATION_NOTES_URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'See the migration notes for details: %s' % _MIGRATION_NOTES_URL | |
'See the migration instructions: %s' % _MIGRATION_NOTES_URL |
Co-Authored-By: Radim Řehůřek <me@radimrehurek.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpenkov something went wrong with your edits.
annual/monthly_rain/2012.monthly_rain.nc 13 | ||
|
||
|
||
Migrating to the New `open` Function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpenkov what happened here? I remember commenting on this line in a review, and you fixing it. But now it's back in the master
README.
|
||
- `profile_name` | ||
|
||
**The `profile_name` parameter has been removed.** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's just the way github renders RST. I don't know what we can do about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaah, this is RST, not Markdown! That explains it.
Literal blocks in RST use double-backticks IIRC, not single-backtick.
Do we need to use RST though? MD easier? Or is it something to do with PyPI relying on RST…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's because of PyPI
See `help("smart_open.open")` for the full list of acceptable parameter names, | ||
or view the help online `here <https://github.com/RaRe-Technologies/smart_open/blob/master/help.txt>`__. | ||
|
||
If you pass an invalid parameter names, the `open` function will warn you about it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:
If you pass an invalid parameter name, the `open` function will warn you about it.
Fix #319